 <{extends file="<{$tempdir}>/public/site.html"}>   
<{block name=extendjs}>
 <script src="<{$siteurl}>/templates/<{$tempdir}>/public/js/cart.js" type="text/javascript" language="javascript"></script>  
   <script src="<{$map_comment_link}>webapi.amap.com/maps?v=1.3&key=<{$map_javascript_key}>"></script>
   <script type="text/javascript" language="javascript" src="<{$siteurl}>/templates/<{$tempdir}>/public/js/jquery.cookie.js"></script>  
 <script>
$(function(){
  var cururl = window.location.href; 
 	 $.cookie('wxCurUrl', cururl); 
	<{if empty($member['uid'])}>
			 location.href= siteurl+'/index.php?ctrl=member&action=login';
	<{/if}>

});
 var site_city = '<{$CITY_NAME|default:$cityname}>';
var shopid = '<{$shopinfo['id']}>';
var pstype = '<{$shopinfo['sendtype']}>';
var addAreaType = '<{$addAreaType}>';
var map_comment_link = '<{$map_comment_link}>';
var map_webservice_key = '<{$map_webservice_key}>';
var mapname = '<{$mapname}>';

  
 //平台配送检查是否在地图勾选区域内 
function checkIsPaPsrange(addresslnglat){
  	var is_exist = false;
	if( addresslnglat != '' && addresslnglat != undefined ){
		var lnglatarr = (addresslnglat).split(','); 
		var addresslnglatarr = []; 
		addresslnglatarr.push(lnglatarr[0]);
		addresslnglatarr.push(lnglatarr[1]); 
 		<{foreach from=$waimai_psrange_arr item=items }>
 		var addressmap ;
		var polygon = new AMap.Polygon({
			map: addressmap,
			path: <{$items|default:0}>
		});  
		if( polygon.contains(addresslnglatarr) ){
			is_exist = true; 
			return is_exist;
		}else{
			is_exist = false; 
		}  
 	<{/foreach}>
	}
	
	return is_exist;
	
} 
 

 </script>
<{/block}>
<{block name=extendcss}> 
<link rel="stylesheet" type="text/css" href="<{$siteurl}>/templates/<{$tempdir}>/public/css/nmmiain.css"> 
<link rel="stylesheet" type="text/css" href="<{$siteurl}>/templates/<{$tempdir}>/public/css/nmcomm.css"> 
<link rel="stylesheet" type="text/css" href="<{$siteurl}>/templates/<{$tempdir}>/public/css/nmage.css"> 
<link rel="stylesheet" type="text/css" href="<{$siteurl}>/templates/<{$tempdir}>/public/css/wmr_new_address.css"> 

<{/block}>
<{block name=sitetitle}><{$mapname}>-附近商家列表<{/block}>
<{block name=shophide}><{/block}>
<{block name=bgshow}><div class="mmbg" <{if !empty($sitebk)}>style="background:#ffffff;"<{/if}>></div> <{/block}>
 <{block name=bodylist}>
 <script src="<{$siteurl}>/templates/<{$tempdir}>/public/js/newaddress.js" type="text/javascript" language="javascript"></script> 
<style>
input{margin:0px;important!}
.input-control input{margin-bottom:0px;}
</style>
<div id="content" class="clearfix" style="min-height: 322px;">
<div class="main">

<section class="breadcrumb">
<a href="/">首页</a>
<i>&gt;</i>
<a href="<{ofunc type=url link="/shop/index/id/<{$shopinfo['id']}>"}>"><{$shopinfo['shopname']}></a>
<i>&gt;</i>
<span>确认订单</span>
</section>
<div class="main-l">
<div class="empty clearfix"></div>


<section id="cartshow_c" class="cart-section fl">

</section>




<section class="delivery fl">
<div class="delivery-title">
<h2>配送信息</h2>
</div>

 <input type="hidden" name="buyerlat" value="">
   <input type="hidden" name="buyerlng" value="">


<div class="takeorderCon">
 <div class="takeorderBox">
  <div class="takeorderL" id="shopinfo_<{$shopid}>">
  
  </div>
  <div class="takeorderR" style="  padding: 0 14px 56px 14px;width: 802px;">
   <div class="takeorderRcon">
     
    <div class="takeorderRintion" id="guestaddresslist" style="display:none;">
   <ul style="display:none;">
      <li style="padding:10px 0 0 0 ;"><a>姓　　名</a><input type="text" name="contactname" placeholder="请输入您的姓名" class="w398 c_khname"><i>*</i>
    
      </li>
      <li style="padding:0 0 10px 0;"><a>手　　机</a><input type="text" name="phone" placeholder="请输入您的手机号" class="w398 c_details_contact"><i>*</i></li>
   
	   <li><a>收餐地址</a><input type="text" name="addresss" placeholder="请输入您的地址" class="w398 c_details_address"><i>*</i></li>
	 
      <li><a>详细地址</a><input type="text" name="detaddresss" placeholder="请输入您的地址" class="w398 c_details_address"><i>*</i></li>
     <li><div class="takeorderRbut" style="padding:0;margin:0 0 0 77px;"><input type="button" value="保存送餐地址" onclick="saveAddress(0);"></div></li>
	  </ul>  
	  
	 <div class="myaddreslist" >
	  
		 <div style="height:100px;line-height:100px;text-align:center; cursor:pointer;"> 
 					<span style="padding-left:30px;background: url(<{$siteurl}>/css/usercenter/images/gh_add_address.png) left center no-repeat;    background-position: -16px -158px;" class="add-new" data-node="addNew">新增送餐地址</span> 
		 </div>
		 
	     <div style="clear:both;"></div>
	</div> 
		 <script>
			$(function(){
				bindaddressclick();
			});
		 </script>
	   
	  
    </div>
	<div class="myaddreslist" id="useraddresslist">
		<ul class="delivery-ul">
			<li class="addr-list-li">	
					<div class="list-title" data-node="listTitle" style="">
						<span>收货人信息：</span>
						<span class="add-new" data-node="addNew">新增送餐地址</span>
					</div>	
			</li>
		</ul> 
		 <ul class="curAddrPanel" data-node="addrPanel" style="height: auto;" id="addressitemlist"> 
		 </ul>
	     <div style="clear:both;"></div>
	</div>
   </div> 
   
  </div>
 </div>
</div>
 


<ul class="delivery-ul">
 

<li class="">
<div class="delivery-lable">
<span class="lable">支付方式：</span>
</div>
<div class="delivery-input" data-node="payMethod">
<table class="pay-list">
<tbody>

<{if !( ( $open_acout == 0   ) && ( $is_daopay == 0   ) )}>

	<{if $open_acout == 1   }>
	<tr data-value="1" class="pay-box select">
	<td class="radio-con">
	<div class="s-radio">
	<i></i>
	</div>
	</td>
	<td class="text">
	<span class="pay-name">支付宝等其他在线支付方式</span>
	<span class="pay-desc"></span>
	</td>
	</tr>
	<{/if}>

	<{if $is_daopay == 1  }>
	<tr data-value="0" class="pay-box <{if $open_acout == 0  }>  select  <{/if}>">
	<td class="radio-con">
	<div class="s-radio">
	<i></i>
	</div>
	</td>
	<td class="text">
	<span class="pay-name">货到付款</span>
	<span class="pay-desc"></span>
	</td>
	</tr>
	<{/if}>
	
<{else}>
	<tr  class="pay-box   select  ">
	<td class="radio-con">
	<div class="s-radio">
	<i></i>
	</div>
	</td>
	<td class="text">
	<span class="pay-name">未开启任何支付方式</span>
	<span class="pay-desc"></span>
	</td>
	</tr>

	
<{/if}>

</tbody></table>
</div>
</li>

<li>
<div class="delivery-lable">
<span class="lable">送达时间：</span>
</div>


	<select name="timeid" id="timeid"  style=" display:; width: 222px;border-radius:0px;margin:0px; height:38px!important; border: 1px solid #e4e4e4;background: #ffffff;"  onchange="doshownewps();">
								   		 <{foreach from=$pstimelist item=itk}>
										<option value="<{$itk['value']}>" pscost="<{$itk['cost']}>"><{$itk['name']}></option>
								 <{/foreach}> 
								  </select> 
							 
						 


</li>
<li id="testdrop">
<div class="delivery-lable">
<span class="lable">备注信息：</span>
</div>
<div style="position:relative;" class="beizhuinfo">
<div class="delivery-input">
<input class="input mark" maxlength="200" name="remark" id="remark" data-node="markInput" value="" placeholder="请填写备注">
<textarea data-node="markInput_list" style="display:none">                  
                </textarea>
</div>
<ul class="mod-dropdown markStyle" style="z-index: 1000; display: none; position: absolute; top: 40px; left: 75px;">

<{if isset($orderbz) &&!empty($orderbz)}>
						<{$orderbz = $orderbz|unserialize}>
						 <{foreach from=$orderbz item=itv}>
						  <{if !empty($itv)}>
				
					
					<li class="mod-dropdown-item" data-value="<{$itv}>" ><a class="s-item" href="javascript: void(0)"><{$itv}></a></li>
					
					
					 <{/if}>
						<{/foreach}> 					
						<{/if}>		
	
</ul>
</div>
</li>
<li>
<div class="delivery-lable">
<span class="lable"></span>
</div>
<div class="delivery-input hide <{if !empty($member['uid'])}> 	delivery-btn <{else}>  delivery-btn-no  <{/if}>" style="display: block;"> 	<!-- -no -->
<span id="showtj"  <{if !empty($member['uid'])}> 	 onclick="orderSubmit();" <{else}>   <{/if}> ><h2>确认下单</h2></span>
<span id="showtj2" style="display:none;"><h2>提交中，请稍等</h2></span>
<a id="continue-to-book"  style="display: none;">继续点餐</a>
</div>
</li>
</ul>
 
</section>
<div class="empty clearfix"></div>
</div>
</div> 
</div>
  
 
 

 
<script type="text/javascript"> 

var juanlist = [];
 
	var cartshopid = '<{$shopid}>';
	var shopid = '<{$shopid}>'; 
	 var starttime = '<{$shopinfo['starttime']}>'; 
	 var is_orderbefore=<{$shopinfo['is_orderbefore']}>;
	 var nowdate = '<{time()|date_format:"%Y-%m-%d"}>';
	 var nowtime = '<{time()|date_format:"%Y-%m-%d %H:%M:%S"}>';
	   <{$yanchitime = time()+$shopinfo['maketime']*60}>
	  var maketime = '<{$yanchitime|date_format:"%Y-%m-%d %H:%M:%S"}>';
	 	var submithtml = '<{ofunc type=url link="/shop/makeorder/datatype/json/random/@random@"}>';
	  var orderhtml = '<{ofunc type=url link="/site/waitpay/orderid/@orderid@"}>';
	  var memberid = <{$member['uid']}>;
	  var xiangxidizhi = '<{$areainfo}>';
var allowedguestbuy = <{$allowedguestbuy|default:0}>;
$(function(){ 	
	//maketimenenu();
	
});

$(".pay-box").click(function(){
	$(this).addClass('select').siblings().removeClass('select');
    freshcart();
});
$(".escBtn").click(function(){
	$(".mod-dialog-frame").hide();
});

$(".s-gender").click(function(){

	$(this).addClass('selected').siblings().removeClass('selected');
});
$("#remark").focus(function(){
	$(".mod-dropdown").show();
});

 $(document).click(function(e){ 
 e = window.event || e; // 兼容IE7
 obj = $(e.srcElement || e.target);
    if ($(obj).is("#testdrop,#testdrop *,.remark")) {
   } else {
     $('.mod-dropdown').hide();//// diaerror('你的点击不在目标区域');
 } 
});

$(".mod-dropdown li a").click(function(){
	var value = $('#remark').val()+$(this).text() + ',';
	$('#remark').val(value);
});
  
 

function addSend_time(obj)
{
	$('#send_time').val($(obj).val());
}
function setaddress(address,contactname,phone,areainfo) 
{
	 $("input[name='addrestemp']").val(areainfo+address);
   $("input[name='phone']").val(phone);
   $("input[name='recieve_name']").val(contactname); 
}

 
$('.beizhubox span').click(function(){
	var value = $('#remark').val()+$(this).text() + ',';
	$('#remark').val(value);
})



//刷新购物车
function freshcart(){ 

var buyerlng = $('input[name="buyerlng"]').val();
var buyerlat = $('input[name="buyerlat"]').val();
 

if($('#ShopCart').html() != undefined){
	    url = siteurl+'/index.php?ctrl=site&action=smallcat&shopid='+shopid+'&buyerlng='+buyerlng+'&buyerlat='+buyerlat+'&random=@random@';
	    url = url.replace('@random@', 1+Math.round(Math.random()*1000)); 
	    $.get(url, function(result){ 
	   
        $("#cartlist").html(result);
         freachperson();
         jifenduihuan();  
		 
      });
   }else{ 
   	//调用  自动刷新购物车  
    var paytype = $(".pay-list tr.select").attr('data-value');
    url = siteurl+'/index.php?ctrl=site&action=smallcat2&shopid='+shopid+'&paytype='+paytype+'&buyerlng='+buyerlng+'&buyerlat='+buyerlat+'&random=@random@';
 
	    url = url.replace('@random@', 1+Math.round(Math.random()*1000)); 
	    $.get(url, function(result){  
         $("#cartshow_c").html(result);  
         if(Number($('#jifendkou').attr('data')) > 0){
  	        $('#jifendkou').show();
         } 
		 doshownewps();
          jifenduihuan();  
		  
      }); 
     
     
   }  
}

function doshownewps(){
	var tempb =  $("select[name='timeid']").find("option:selected").attr('pscost'); 
		 if(tempb > 0){
		    $('#fups').show();
			$('#sendFee1').text(tempb);
			var tempc = Number(tempb)+Number($('#total_money').attr('data'));
			$('#total_money').text(tempc.toFixed(2));
		 }else{
			$('#fups').hide();
			$('#total_money').text($('#total_money').attr('data'));
		 }
}

function  orderSubmit(){
 	 $('#showtj').hide();
	 $('#showtj2').show();
	  url = submithtml.replace('@random@', 1+Math.round(Math.random()*1000));
	
 <{if !empty($member['uid'])}> 	
	var contactname = $(".curAddrPanel li.select .name").text();
	var phone = $(".curAddrPanel li.select .sex").text();
	var address = $(".curAddrPanel li.select .addr-desc").text();	
<{else}>
	var contactname = $("input[name='user_name']").val();
	var phone = $("input[name='user_phone']").val();
	var address = $("input[name='detail_address']").val();
<{/if}> 

	var buyerlng = $("input[name='buyerlng']").val();
	var buyerlat = $("input[name='buyerlat']").val(); 

	var ordercheckphone = <{$ordercheckphone}>;

	if( ordercheckphone == 1 ){
		if($('#cat_zhe').is(":hidden") == true){
			 $('#cat_zhe').show();
			 $('#goosshow').show();
			 $('#phonefont').text(phone);
			 return ;
		}

	} 
 
	
	var remark = $("#remark").val();
	var paytype = $(".pay-list tr.select").attr('data-value');
	if( paytype == undefined){
		 $('#showtj2').hide();
	              $('#showtj').show();
		diaerror("未开启任何支付方式，请联系管理员！");	
		return false;
	}

   $.ajax({         //script定义
             url: url.replace('@random@', 1+Math.round(Math.random()*1000)),
            dataType: "json",
            async:true,
            data:{'phonecode':$('#phonecode').val(),'shopid':shopid,'buyerlng':buyerlng,'buyerlat':buyerlat,'remark':remark,'username':contactname,'mobile':phone,'addressdet':address,'areaid1':$("#areaid1").find("option:selected").val(),'areaid2':$("#areaid2").find("option:selected").val(),'areaid3':$("#areaid3").find("option:selected").val(),'senddate':'','minit':$("#timeid").find("option:selected").val(),'paytype':paytype,'dikou':$("select[name='jfdk']").find("option:selected").val(),'juanid':$("input[name='buyjuan']:checked").val()},
            success:function(content) { 
			
			
            //	$('#loading').toggle();
             if(content.error == true){ 
                $('#showtj2').hide();
	              $('#showtj').show();
	              diaerror(content.msg);
             }else{
             
	             window.location.href= orderhtml.replace('@orderid@', content.msg);
             }
            },
            error:function(){
            	 $('#showtj2').hide();
	              $('#showtj').show();
            	//$('#loading').toggle();
            	diaerror('数据提交失败');
            }
   });     
}
</script>
 

<div id="cat_zhe" class="cart_zhe" style="display:none;"></div>
<div id="goosshow" class="cart_position" style="display:none;">
	 <form id="dosubmit">
		 <div class="position_top"><span class="title">验证手机</span><i class="close" onclick="close_pop('goosshow')"></i></div>
		 <div class="goodsshow" style="padding:20px;">为了保证您的用餐请验证您的手机号</div>
		 <div class="position_middel"> 
		  <div class="line_class"><label>联系电话:</label><font id="phonefont">0</font></div>
		  <div class="line_class"><label>获取验证码:</label><input type="button" value="发送手机验证码" id="dosendbtn" time="0" style="line-height:15px;"></div>
		  <div class="line_class"><label>验证码:</label><input type="text" name="phonecode" id="phonecode" value=""></div> 
		  <div class="line_class">  <input type="hidden" name="shopid" value="13"><input type="hidden" name="subtype" value="1"><input type="button" class="next bg" value="确认提交" id="cfbtn" onclick="orderSubmit()"></div>
		 </div> 
		</form>
</div>
<style>
.cart_position  .position_middel input{ border:1px solid;}
	.cart_position{width: 400px;height: 400px;position: fixed;z-index: 1050;background-color: #fff;left: 50%;top: 50%;margin-left: -200px;margin-top:-200px;border:4px solid #da3838;border-radius: 5px;}
.cart_position .position_top{height:40px;line-height:40px;text-align:center;font-weight:bold;color:#fff;}
.cart_position .position_top .title{padding-left:20px;padding-right:20px;background-color:#da3838;line-height:30px;height:30px;padding-top:10px;padding-bottom:11px;}
.cart_position .position_top  i{width: 21px;height: 21px;position:absolute;margin-right: 5px;margin-top: 5px;background: url(<{$siteurl}>/templates/<{$tempdir}>/public/images/plate/icon.png) no-repeat;background-position: -362px -92px;cursor: pointer;right:0px;}
.cart_position  .position_middel .line_class{height:30px;line-height:30px;padding-left:20px;clear:both;margin-top:10px;}
.cart_position  .position_middel .line_class label{width:80px;float:left;line-height:30px;height:30px;}
.cart_position  .position_middel .line_class select{width:100px;padding:0px;height:30px;line-height:30px;float:left;}
.cart_position  .position_middel .line_class input{float:left;border:1px solid;}
.cart_position  .position_middel .line_class .next{width: 120px;margin-top: 10px;height: 30px;line-height: 30px;font-size: 16px;color: #fff;border: none;margin-left: 10px;cursor: pointer;}
.cart_position  .position_middel .line_class .bg{background: #da3838;cursor: pointer;}
.cart_position  .position_middel .line_class .bg:hover{background: #e51914}
.cart_position  .position_middel .line_class .diabled{background-color:#ccc;}
.cart_position  .position_middel .line_class .diabled:hover{background-color:#ccc;}
.cart_position  .position_middel .mutile_class{clear:both;float:left;margin-top:10px;padding-left:20px;height:80px;} 
.cart_position  .position_middel .mutile_class label{width:80px;float:left;}
.cart_position  .position_middel .mutile_class textarea{height:70px;float:left;width:280px;}
</style>
<script>
	function close_pop(divid){
	  $('#'+divid).hide();//phone
	  $('#cat_zhe').hide();
	  $('#showtj2').hide();
	              $('#showtj').show();
	}
	$(function(){    
   	     $('#dosendbtn').bind("click", function() {  
   	     	   $('#dosendbtn').attr('disabled',true); 
   	     	   $('#dosendbtn').attr('value','发送中..');
   	 	       var tempurl = siteurl+'/index.php?ctrl=site&action=phonecode&random=@random@&phone=@phone@';
			    <{if !empty($member['uid'])}> 	
					tempurl = tempurl.replace('@random@', 1+Math.round(Math.random()*1000)).replace('@phone@',$(".curAddrPanel li.select .phone").text() );
				<{else}>
					tempurl = tempurl.replace('@random@', 1+Math.round(Math.random()*1000)).replace('@phone@',$("input[name='user_phone']").val() );
				<{/if}>
	            $.getScript(tempurl);      
         }); 
  }); 
function showsend(phone,time){  
     $('#dosendbtn').attr('time',time);
     setTimeout("btntime()",1000);  
} 
function showmessage(msg){
	 diaerror(msg);
	  $('#dosendbtn').attr('disabled',false);
		 $('#dosendbtn').attr('value','发送手机验证码');
}
function  btntime(){
	//dosendbtn
	var nowtime = Number($('#dosendbtn').attr('time'));
	if(nowtime > 0){
	   $('#dosendbtn').attr('disabled',true);
	   var c = Number(nowtime)-1;
	    $('#dosendbtn').attr('time',c);
	    var  mx = 60-(60 - Number(c));
	     $('#dosendbtn').attr('value','验证码还有'+mx+'秒失效');
	      setTimeout("btntime()",1000);
	}else{
		 $('#dosendbtn').attr('disabled',false);
		 $('#dosendbtn').attr('value','发送手机验证码');
  }
}
</script>
<style>
.addr-item .addr-title .addr-user{width:140px;}
.addr-item .addr-title .addr-user .sex{max-width:100px;}
.addr-item{width:220px;height:100px;}
.aui_inner{background:#FFF!important;}
</style>
<{/block}>